import { Empty } from 'antd'

export const useFormEdit = ({
  SupplierAppListOptions,
  isEdit,
  SupplierOption,
  handleSearchSupplier,
}: {
  SupplierAppListOptions: IOptionItem[]
  SupplierOption: IOptionItem[]
  handleSearchSupplier: (newValue: string) => void
  isEdit: boolean
}): IItemArray[] => {
  return [
    {
      name: 'name',
      label: '组织名称',
      type: 'Input',
      placeholder: '请输入组织名称',
      rules: [
        {
          required: true,
          message: '请输入组织名称',
        },
      ],
      config: {
        showCount: true,
        maxLength: 30,
        disabled: !!isEdit,
      },
    },
    {
      name: 'code',
      label: '组织编码',
      type: 'Input',
      placeholder: '请输入组织编码',
      rules: [
        {
          required: true,
          message: '请输入组织编码',
        },
      ],
      config: {
        showCount: true,
        maxLength: 30,
        disabled: !!isEdit,
      },
    },
    {
      name: 'description',
      label: '组织描述',
      type: 'TextArea',
      placeholder: '请输入组织描述',
      rules: [
        {
          required: true,
          message: '请输入组织描述',
        },
      ],
      config: {
        showCount: true,
        maxLength: 100,
      },
    },
    {
      name: 'applications',
      label: '可用应用',
      type: 'Select',
      option: SupplierAppListOptions,
      placeholder: '请选择可用应用',
      rules: [
        {
          required: true,
          message: '请选择可用应用',
        },
      ],
      config: {
        mode: 'multiple',
        optionFilterProp: 'label',
      },
    },
    {
      name: 'suppliers',
      label: '可分配供应商',
      type: 'Select',
      option: SupplierOption,
      placeholder: '请选择可分配供应商',
      rules: [
        {
          required: true,
          message: '请选择可分配供应商',
        },
      ],
      config: {
        mode: 'multiple',
        suffixIcon: null,
        showSearch: true,
        optionFilterProp: 'label',
        filterOption: false,
        onSearch: handleSearchSupplier,
        notFoundContent: <Empty description="请输入内容搜索" image={Empty.PRESENTED_IMAGE_SIMPLE} />,
      },
    },
  ]
}

export const useFormAdd = (): IItemArray[] => {
  return [
    {
      name: 'id',
      label: '产品id',
      type: 'Input',
      config: {
        disabled: true,
      },
    },
    {
      name: 'materials',
      label: '产品名称',
      type: 'Input',
      placeholder: '请输入产品名称',
      rules: [{ required: true, message: '请输入产品名称' }],
    },
    {
      name: '1',
      label: '产品型号',
      type: 'Input',
      placeholder: '请输入产品型号',
      rules: [{ required: true, message: '请输入产品型号' }],
    },
    {
      name: '2',
      label: '厂商',
      type: 'Input',
      placeholder: '请输入厂商',
      rules: [{ required: true, message: '请输入厂商' }],
    },
    {
      name: 'category',
      label: '产品类型',
      type: 'Select',
      placeholder: '请选择产品类型',
      rules: [
        {
          required: true,
          message: '请选择产品类型',
        },
      ],
    },
    {
      name: 'cover_img',
      label: '产品图片',
      config: { max: 1 },
      type: 'Upload',
    },
    {
      name: 'desc',
      label: '激活方式',
      type: 'TextArea',
      config: { rows: 4, showCount: true, maxLength: 30 },
      placeholder: '请输入激活方式',
    },
    {
      name: 'desc1',
      label: '对接方式',
      type: 'TextArea',
      config: { rows: 4, showCount: true, maxLength: 30 },
      placeholder: '请输入对接方式',
    },
  ]
}
